#!/bin/bash
# backup.sh
# Written by James Kelly <kellyjh@dcs.gla.ac.uk>
# Used with permission.
# This program recursively backs up files.
# Create tar from the current date


Sha1_recursively () {
# Gives each individual file a sha1sum
for file in `ls $1`;  do

if [ -d $1/$file ];  then # If file is a directory
		echo "Directory: ";
		add_directory $1/$file 
	else   
	 	# Change to a Temp file
		sha1sum $1/$file >> ~/$BACKUPFILE-SHA1SUMS.log  
		echo $1/$file
fi
done
}


BACKUPFILE=backup-$(date +%m-%d-%Y)
archive=${1:-$BACKUPFILE}
add_directory $PWD
tar cvf - `find . -mtime -1 -type f -print` > $archive.tar
gzip $archive.tar
echo "Directory $PWD backed up in archive file \"$archive.tar.gz\"."
exit 0

